package com.wangshang.general.commodity.dao;

import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.wangshang.general.commodity.po.CommoditiesInPlace;
import com.wangshang.general.commodity.po.CommoditiesInPlaceId;

/**
 * A data access object (DAO) providing persistence and search support for
 * CommoditiesInPlace entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.wangshang.general.commodity.po.CommoditiesInPlace
 * @author MyEclipse Persistence Tools
 */

public class CommoditiesInPlaceDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory
			.getLog(CommoditiesInPlaceDAO.class);
	// property constants
	public static final String PLACE_MASK = "placeMask";
	public static final String PRICE_OUR = "priceOur";
	public static final String VIP_PRICE1 = "vipPrice1";
	public static final String VIP_PRICE2 = "vipPrice2";
	public static final String VIP_PRICE3 = "vipPrice3";
	public static final String PRICE_OTHER = "priceOther";
	public static final String AFTER_SERVICE = "afterService";
	public static final String DELIVERY_REQ = "deliveryReq";
	public static final String SHOP_NAME = "shopName";
	public static final String SHOP_ADDR = "shopAddr";
	public static final String SHOP_CONNECT = "shopConnect";
	public static final String PICTURE_PATH = "picturePath";
	public static final String COMMODITY_STATUS = "commodityStatus";
	public static final String NORM1 = "norm1";
	public static final String NORM2 = "norm2";
	public static final String NORM3 = "norm3";
	public static final String NORM4 = "norm4";
	public static final String NORM5 = "norm5";
	public static final String NORM6 = "norm6";
	public static final String NORM7 = "norm7";
	public static final String NORM8 = "norm8";
	public static final String SAY_SOMETHING = "saySomething";
	public static final String COMMODITY_SOURCE_PLACE_ID = "commoditySourcePlaceId";

	protected void initDao() {
		// do nothing
	}

	public void save(CommoditiesInPlace transientInstance) {
		log.debug("saving CommoditiesInPlace instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(CommoditiesInPlace persistentInstance) {
		log.debug("deleting CommoditiesInPlace instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public CommoditiesInPlace findById(
			com.wangshang.general.commodity.po.CommoditiesInPlaceId id) {
		log.debug("getting CommoditiesInPlace instance with id: " + id);
		try {
			CommoditiesInPlace instance = (CommoditiesInPlace) getHibernateTemplate()
					.get("com.wangshang.general.commodity.CommoditiesInPlace",
							id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List findByExample(CommoditiesInPlace instance) {
		log.debug("finding CommoditiesInPlace instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding CommoditiesInPlace instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from CommoditiesInPlace as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List findByPlaceMask(Object placeMask) {
		return findByProperty(PLACE_MASK, placeMask);
	}

	public List findByPriceOur(Object priceOur) {
		return findByProperty(PRICE_OUR, priceOur);
	}

	public List findByVipPrice1(Object vipPrice1) {
		return findByProperty(VIP_PRICE1, vipPrice1);
	}

	public List findByVipPrice2(Object vipPrice2) {
		return findByProperty(VIP_PRICE2, vipPrice2);
	}

	public List findByVipPrice3(Object vipPrice3) {
		return findByProperty(VIP_PRICE3, vipPrice3);
	}

	public List findByPriceOther(Object priceOther) {
		return findByProperty(PRICE_OTHER, priceOther);
	}

	public List findByAfterService(Object afterService) {
		return findByProperty(AFTER_SERVICE, afterService);
	}

	public List findByDeliveryReq(Object deliveryReq) {
		return findByProperty(DELIVERY_REQ, deliveryReq);
	}

	public List findByShopName(Object shopName) {
		return findByProperty(SHOP_NAME, shopName);
	}

	public List findByShopAddr(Object shopAddr) {
		return findByProperty(SHOP_ADDR, shopAddr);
	}

	public List findByShopConnect(Object shopConnect) {
		return findByProperty(SHOP_CONNECT, shopConnect);
	}

	public List findByPicturePath(Object picturePath) {
		return findByProperty(PICTURE_PATH, picturePath);
	}

	public List findByCommodityStatus(Object commodityStatus) {
		return findByProperty(COMMODITY_STATUS, commodityStatus);
	}

	public List findByNorm1(Object norm1) {
		return findByProperty(NORM1, norm1);
	}

	public List findByNorm2(Object norm2) {
		return findByProperty(NORM2, norm2);
	}

	public List findByNorm3(Object norm3) {
		return findByProperty(NORM3, norm3);
	}

	public List findByNorm4(Object norm4) {
		return findByProperty(NORM4, norm4);
	}

	public List findByNorm5(Object norm5) {
		return findByProperty(NORM5, norm5);
	}

	public List findByNorm6(Object norm6) {
		return findByProperty(NORM6, norm6);
	}

	public List findByNorm7(Object norm7) {
		return findByProperty(NORM7, norm7);
	}

	public List findByNorm8(Object norm8) {
		return findByProperty(NORM8, norm8);
	}

	public List findBySaySomething(Object saySomething) {
		return findByProperty(SAY_SOMETHING, saySomething);
	}

	public List findByCommoditySourcePlaceId(Object commoditySourcePlaceId) {
		return findByProperty(COMMODITY_SOURCE_PLACE_ID, commoditySourcePlaceId);
	}

	public List findAll() {
		log.debug("finding all CommoditiesInPlace instances");
		try {
			String queryString = "from CommoditiesInPlace";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public CommoditiesInPlace merge(CommoditiesInPlace detachedInstance) {
		log.debug("merging CommoditiesInPlace instance");
		try {
			CommoditiesInPlace result = (CommoditiesInPlace) getHibernateTemplate()
					.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(CommoditiesInPlace instance) {
		log.debug("attaching dirty CommoditiesInPlace instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(CommoditiesInPlace instance) {
		log.debug("attaching clean CommoditiesInPlace instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static CommoditiesInPlaceDAO getFromApplicationContext(
			ApplicationContext ctx) {
		return (CommoditiesInPlaceDAO) ctx.getBean("CommoditiesInPlaceDAO");
	}
}